-- Decompiled with the Synapse X Luau decompiler.

--单例 永久存在

local ClientOHOH = _G.ClientOHOH;
local FunctionList = ClientOHOH.load.FunctionList();
FunctionList.create_character = true;
local event_manager = ClientOHOH.event_manager();

local CommonOHOH =_G.CommonOHOH
local ConnectClass=CommonOHOH.load.Connect();
local training_cfg = ClientOHOH.config.Training
local game_cfg = ClientOHOH.config.Game
local LanguageHelper=_G.CommonOHOH.LanguageHelper 
local Client_AudioManager = ClientOHOH.load.Client_AudioManager();

local M = ClientOHOH.class.new(script, ClientOHOH.files.Client_PlayerObject());

local TeleportService = game:GetService("TeleportService")


function M.new(p1)
	return M(p1);
end;

function M.ctor(self, player)
	_G.CommonOHOH.load.PlayerTool().CreateConnectEvent(self)

	M.super.ctor(self, player);

	self.DataBase =self:GetComponent(ClientOHOH.load.Client_PlayerDataComponent())
end;



function M.dtor(self)

	if self.UserDataEvent then
		self.UserDataEvent:dtor()
		self.UserDataEvent=nil
	end

	M.super.dtor(self);
end;

-- 收服务器的数据同步
function M.SynchDataFormeServer(self,data)
	assert(self.DataBase,"self.DataBase==null")
	for key,value in pairs(data) do
		self.DataBase:UpdateData(key,value)
	end
	self.UserDataEvent:Action(data)
end


--已经有数据了（构建的player实例（ctor）的时候，就会调用）
function M.OnLogin(self)


end;

--通知服务器登录完成后调用客户端登录完成 （构建的player实例（ctor）的时候，就会调用）
function M.OnLoginOver(self)
	self:AddComponent(_G.CommonOHOH.load.Common_MatchCtrl()); 

	self:AddComponent(_G.CommonOHOH.load.Common_PaveCtrl()); 
	self:AddComponent(_G.CommonOHOH.load.Common_ReadyCtrl()); 
	self:AddComponent(_G.CommonOHOH.load.Common_ShowCtrl()); 
	self:AddComponent(_G.CommonOHOH.load.CharacterAnimationCtrl()); 
	self:AddComponent(_G.CommonOHOH.load.Common_TrailCtrl()); 
	self:AddComponent(_G.CommonOHOH.load.Common_DrillCtrl()); 
end;



function M.CreateCharacter(self)
	self:Invoke(FunctionList.create_character);
end;

function M.OnCharacterIn(self, Character)
	self.CharacterEnterEvent:Action(Character)

end;

function M.OnCharacterOut(self, p12)

end;



--服务器通知客户端创建游戏对象控制器
event_manager:RegistHandle(ClientOHOH.event_list.server_GameObject_Control, function(player, gameObject, GameObjectControlClass)
	print("服务器说 创建游戏对象 控制器:",gameObject,GameObjectControlClass)
	ClientOHOH.load[GameObjectControlClass]().new(gameObject)
end);

event_manager:RegistHandle(ClientOHOH.event_list.synch_userdata, function(player,data)
	player:SynchDataFormeServer(data)

end);

return M;
